package cn.wynu.mapper;

import cn.wynu.mode.ChangePassword;
import cn.wynu.mode.RegisterUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Insert("insert into users (username, password, role, phone) " +
            "values(#{username}, #{password}, #{role}, #{phone})")
    Integer registerUser(RegisterUser registerUser);

    @Select("select * from users where username = #{username}")
    RegisterUser getUserInfoByUserName(String username);

    @Update("UPDATE USERS SET PASSWORD = #{newPassword} WHERE USERNAME = #{username}")
    Integer changePasswd(ChangePassword changePasswd);
}
